package com.hrbxlh.virtualization.converter;

import com.hrbxlh.virtualization.param.ClusterAutoCreateParam;
import com.hrbxlh.virtualization.pojo.Cluster;
import com.hrbxlh.virtualization.util.SessionUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

/**
 * @author cheer
 */
@Component
public class ClusterAutoCreateParamToClusterConverter implements Converter<ClusterAutoCreateParam, Cluster> {

    @Override
    public Cluster convert(ClusterAutoCreateParam clusterAutoCreateParam) {
        Cluster cluster = new Cluster();
        BeanUtils.copyProperties(clusterAutoCreateParam, cluster);
        cluster.setInitial(false);
        cluster.setStuorteaId(SessionUtil.getStuorteaId());
        cluster.setBroken(false);
        return cluster;
    }
}
